package com.ruoyi.web.controller.award.party;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.award.party.PartyAwardInfo;
import com.ruoyi.system.service.award.party.IPartyAwardInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 党建获奖Controller
 * 
 * @author ruoyi
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/award/party")
public class PartyAwardInfoController extends BaseController
{
    @Autowired
    private IPartyAwardInfoService partyAwardInfoService;

    /**
     * 查询党建获奖列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PartyAwardInfo partyAwardInfo)
    {
        startPage();
        List<PartyAwardInfo> list = partyAwardInfoService.selectPartyAwardInfoList(partyAwardInfo);
        return getDataTable(list);
    }

    /**
     * 导出党建获奖列表
     */
    @Log(title = "党建获奖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PartyAwardInfo partyAwardInfo)
    {
        List<PartyAwardInfo> list = partyAwardInfoService.selectPartyAwardInfoList(partyAwardInfo);
        ExcelUtil<PartyAwardInfo> util = new ExcelUtil<PartyAwardInfo>(PartyAwardInfo.class);
        util.exportExcel(response, list, "党建获奖数据");
    }

    /**
     * 获取党建获奖详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(partyAwardInfoService.selectPartyAwardInfoById(id));
    }

    /**
     * 新增党建获奖
     */
    @Log(title = "党建获奖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PartyAwardInfo partyAwardInfo)
    {
        return toAjax(partyAwardInfoService.insertPartyAwardInfo(partyAwardInfo));
    }

    /**
     * 修改党建获奖
     */
    @Log(title = "党建获奖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PartyAwardInfo partyAwardInfo)
    {
        return toAjax(partyAwardInfoService.updatePartyAwardInfo(partyAwardInfo));
    }

    /**
     * 删除党建获奖
     */
    @Log(title = "党建获奖", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(partyAwardInfoService.deletePartyAwardInfoByIds(ids));
    }
}
